zsh 优化

  • ~3.16K 字
  1. 1. Brew
  2. 2. oh-my-zsh
  3. 3. Powerline
  4. 4. SourceCodePro+Powerline+Awesome+Regular.ttf)
  5. 5. fonts-powerline
  6. 6. font-sauce-code-pro-nerd-font
  7. 7. 安装插件
    1. 7.1. zsh-syntax-highlighting
    2. 7.2. zsh-completions
    3. 7.3. zsh-autosuggestions
    4. 7.4. incr
    5. 7.5. autojump
    6. 7.6. zsh-you-should-use
    7. 7.7. autoupdate-oh-my-zsh-plugins
  8. 8. 主题美化

Brew

Homebrew 软件包的管理器

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

oh-my-zsh

基于zsh命令行,提供了主题配置,插件机制,内置便捷操作

## curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
## wget
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

Powerline

全局状态/提示栏

pip install powerline-status --user

如果没有,则先执行安装pip指令

sudo easy_install pip

SourceCodePro+Powerline+Awesome+Regular.ttf)

wget -P /Library/Fonts/ https://raw.githubusercontent.com/Falkor/dotfiles/master/fonts/SourceCodePro%2BPowerline%2BAwesome%2BRegular.ttf

fonts-powerline

git clone https:*//github.com/powerline/fonts.git --depth=1*
cd fonts
./install.sh
cd ..
rm -rf fonts

font-sauce-code-pro-nerd-font

brew install --cask font-sauce-code-pro-nerd-font

安装插件

zsh-syntax-highlighting

  • 语法高亮
 git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting --depth=1
 

zsh-completions

  • 自动补全
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions --depth=1

zsh-autosuggestions

  • 自动补全
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions --depth=1

incr

  • 实时补全(电脑性能消耗多点)
mkdir $ZSH_CUSTOM/plugins/incr

curl -fsSL https://mimosa-pudica.net/src/incr-0.2.zsh -o $ZSH_CUSTOM/plugins/incr/incr.zsh

echo 'source $ZSH_CUSTOM/plugins/incr/incr.zsh' >> ~/.zshrc

source ~/.zshrc

autojump

  • 快去切换
brew install autojump

# 在.zshrc文件末尾添加

[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh

zsh-you-should-use

  • 别名提示
git clone https://github.com/MichaelAquilina/zsh-you-should-use.git $ZSH_CUSTOM/plugins/you-should-use --depth=1

autoupdate-oh-my-zsh-plugins

  • oh-my-zsh-plugins update
git clone https://github.com/TamCore/autoupdate-oh-my-zsh-plugins $ZSH_CUSTOM/plugins/autoupdate --depth=1
  • ~/.zshrc配置

# to check for updates once a month

export UPDATE_ZSH_DAYS=30

# Uncomment the following line to change how often to auto-update (in days).

ZSH_CUSTOM_AUTOUPDATE_QUIET=true

# Values accepted (min: 1, max: 16)
# Parallel downloads will not be enabled if value is out-of-range

ZSH_CUSTOM_AUTOUPDATE_NUM_WORKERS=8
  • 找到zhsrc配置文件中的plugin,将插件名写入就能使用插件
plugins=(
    git
    sudo
    brew
    python
    docker
    autojump
    autopep8
    autoupdate
    docker-compose
    you-should-use
    zsh-completions
    zsh-autosuggestions
    zsh-syntax-highlighting
)

主题美化

  • powerlevel10k
git clone https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k --depth=1

zsh中主题配置


*# PowerLevel10k*

ZSH_THEME="powerlevel10k/powerlevel10k"

# 字体

typeset -g POWERLEVEL9K_MODE=nerdfont-complete

# 新起一行显示命令

POWERLEVEL9K_PROMPT_ON_NEWLINE=true

# 右侧状态栏与命令在同一行

POWERLEVEL9K_RPROMPT_ON_NEWLINE=false

# 右侧栏目显示的要素

POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=('time')
POWERLEVEL9K_TIME_FORMAT="%D